<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="format-detection" content="telephone=yes" />
    <meta name="format-detection" content="email=yes" />
    <meta name="format-detection" content="address=yes" />
    <script src="js/jquery-1.9.1.js" type="text/javascript"></script>
    <script src="js/json2.js" type="text/javascript"></script>
    <script src="js/taskForm.js" type="text/javascript"></script>
    <script src="js/common.js" type="text/javascript"></script>
    <script src="js/ajaxfileupload.js" type="text/javascript"></script>
    <link href="miniui3.5/themes/default/miniui.css" rel="stylesheet" type="text/css" />
    <link href="miniui3.5/themes/icons.css" rel="stylesheet" type="text/css" />
    <link href="css/taskForm.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="kindeditor/themes/default/default.css" />
    <link rel="stylesheet" href="kindeditor/plugins/code/prettify.css" />
    <script charset="utf-8" src="kindeditor/kindeditor.js"></script>
    <script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>
    <script charset="utf-8" src="kindeditor/plugins/code/prettify.js"></script>
</head>
<body id="body" fieldkey="body" style="-webkit-overflow-scrolling:touch;overflow:auto;background-color: #fff;" >

<script src="miniui3.5/miniui.js" type="text/javascript"></script>
<script src="js/processTask.js" type="text/javascript"></script>
<script type="text/javascript">
    try{
        loadForm(getQueryString("id"))
    }catch (e){
    }
    function loadForm(id) {
        requestServlet("getTaskFormDetail",{taskid:id},function(rs){
            var form = rs.form;
            var tree = rs.tree;
            var id = rs.id;
            var name = rs.name;
            var status = rs.status;
            var isMyTask = rs.isMyTask;
            document.title = name;
            loads(form, tree.tree, id);
            mini.parse();
            var grids = $(".mini-datagrid");
            for(var i=0;i<grids.length;i++){
                var grid = mini.get(grids.eq(i).attr("id"));
                grid.setData(allGridData[grids.eq(i).attr("id")])
                $("#"+grids.eq(i).attr("id")+"Columns").val(allGridData[grids.eq(i).attr("id")+"ColumnsNoName"]);
            }
            executeEvent(formId,"load");
            for(var i=0;i<gridTextFileUploadData.length;i++){
                var gridId = gridTextFileUploadData[i].gridId;
                var fieldName = gridTextFileUploadData[i].fieldName;
                mini.get(gridId).updateColumn(mini.get(gridId).getColumn(fieldName),{"readOnly":true});
                mini.get(gridId).on("drawcell", function (e) {
                    var record = e.record;
                    var column = e.column;
                    var field = e.field;
                    var value = e.value;
                    var rowIndex = e.rowIndex;
                    if (column.filePath!=null) {
                        var filePath = column.filePath;
                        var gridId = column.gridId;
                        var row = grid.getRow(rowIndex);
                        var fileLink="";
                        var uploadText = "上传文件";
                        var readOnly  = column.readOnlyFile;
                        var deleteFile ="";
                        if(value!=null&&value!=""&&value!=" "){
                            fileLink='<a style="text-decoration:none;" href="/suite/doc/'+value.split("#")[0]+'" >'+value.split("#")[1]+'</a>'
                            uploadText = "修改文件";
                            deleteFile ='<a style="text-decoration:none;" href=javascript:deleteDocumentGridTextFileUpload("'+value.split("#")[0]+'","'+gridId+'",'+rowIndex+',"'+field+'")  >删除</a>';
                        }
                        if(readOnly=="true"){
                            e.cellHtml=fileLink;
                        }else{
                            e.cellHtml=fileLink+'&nbsp;&nbsp;'+deleteFile+'&nbsp;&nbsp;<a  href="javascript:;" style="position: relative;display: inline-block;text-decoration:none;"  >'+uploadText+'<input type="file" style="position: absolute;font-size: 100px;right: 0;top: 0;opacity: 0;width: 60px;" id="fileUpload'+field+rowIndex+'"  onchange=selectedFileGridTextFileUpload("fileUpload'+field+rowIndex+'","'+gridId+'",'+rowIndex+',"'+field+'","'+filePath+'") name="upload"  /></a>';
                        }
                    }
                });
            }
            var form = new mini.Form("#"+formId);
            if(isMyTask==false){
                form.setEnabled(false);
                for(var i=0;i<grids.length;i++){
                    var grid = mini.get(grids.eq(i).attr("id"));
                    grid.setEnabled(false);
                }
                $(".mini-toolbar .toolbar-edit").remove();
                $("#"+formId+"Buttons>a").hide()
                $(".a-upload>input").attr("disabled","disabled")
            }
            window.parent.postMessage('{"type":"setHeight","height":"'+$(document).height()+'"}','*');
			//window.parent.$("#taskContent").height($(document).height());
        },function(msg){});
    }
    window.addEventListener('message',function(e){
		var data = JSON.parse(e.data)
        if(data.type=="save"){
            taskSave();
        }
    },false);
</script>


</body>

</html>
